/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package edu.lnu.ums.dal.impl;

import edu.lnu.ums.dal.ICharity;
import edu.lnu.ums.entities.Charity;
import javax.ejb.Stateless;
import javax.persistence.EntityManager;
import javax.persistence.EntityManagerFactory;

/**
 *
 * @author Orysia
 */
@Stateless
public class CharityDAO extends AbstractNoConcurrentAccessGenericDAO<Charity> implements ICharity {

    public CharityDAO() {
        super(Charity.class);
    }

    @Override
    public void delete(Charity obj) {
        throw new UnsupportedOperationException("Not supported yet.");
    }

    @Override
    public String getOrderByQuery() {
       return "";
    }

     @SuppressWarnings("unchecked")
     public Charity getDonationByYear(EntityManagerFactory factory, String year, Long procId){
        EntityManager em = factory.createEntityManager();
        Charity t =(Charity) em.createQuery("from Charity where years="+year+" and charparent="+procId).getSingleResult();
        em.close();
        setEntityManagerFactoryToEntity(factory, t);
        return t;
     }

}
